package com.shuoyue.ycgk.base.baseadapter;


import android.view.ViewGroup;

import androidx.fragment.app.FragmentManager;

import com.shuoyue.appdepends.view.BaseFragmentPagerAdapter;
import com.shuoyue.ycgk.base.BaseMvpFragment;

import java.util.List;

public class IndexFragmentAdapter extends BaseFragmentPagerAdapter<BaseMvpFragment> {

    private List<BaseMvpFragment> mDatas;
    BaseMvpFragment mCurrentFragment;

    public IndexFragmentAdapter(FragmentManager fm, List<BaseMvpFragment> mDatas) {
        super(fm, mDatas);
        this.mDatas = mDatas;
    }

    @Override
    protected BaseMvpFragment getFragmentItem(int position) {
        return mDatas.get(position);
    }

    @Override
    protected CharSequence getTitle(BaseMvpFragment data) {
        return data.getTitle();
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        mCurrentFragment = (BaseMvpFragment) object;
        super.setPrimaryItem(container, position, object);
    }


    public BaseMvpFragment getCurrentFragment() {
        return mCurrentFragment;
    }
}

